package com.xy.annotaion.handler.listener;

import com.xy.annotaion.handler.common.log.LogService;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Arrays;

/**
 * @author Dell
 */
public class TestSpringApplicationRunListener implements SpringApplicationRunListener, LogService {

    public TestSpringApplicationRunListener(SpringApplication application, String []args){
        log(application, Arrays.asList(args));
    }

    @Override
    public void starting(ConfigurableBootstrapContext bootstrapContext) {
        log(bootstrapContext);
    }

    @Override
    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
        log(bootstrapContext, environment);
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        log(context);
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        log(context);
    }

    @Override
    public void started(ConfigurableApplicationContext context) {
        log(context);
    }

    @Override
    public void running(ConfigurableApplicationContext context) {
        log(context);
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        log(context, exception);
    }
}
